Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Surface parameters fields for database model #14646

Closed
wants to merge 2 commits into from

Conversation

hughhhh
Copy link
Member

@hughhhh hughhhh commented May 14, 2021

SUMMARY

Update the api to surface parameters in GET database. This will be leveraged for whenever a user wants to edit a database assuming configuration type is dynamic.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TEST PLAN

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@betodealmeida betodealmeida self-requested a review May 14, 2021 17:13
host: string;
password?: string;
port: number;
query: Object;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better to use the query props here, which I think you can import.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh interesting, so then would Record<string, string> be more explicit here given that it has string keys and values?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds like a good plan.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also added in some props in #14583. For bigquery most of those props are going be optional (maybe some other dbs too). Are we going to use db parameters for Gsheets for example?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AAfghahi right, Record<string, string>

But we need to keep in mind that these are specific for Postgres and similar databases. For other DBs some attributes might be optional, or there might be a different set of attributes, so maybe we should just define the type as Object.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's fair, I hadn't considered that.

@codecov
Copy link

codecov bot commented May 14, 2021

Codecov Report

Merging #14646 (5f30cee) into master (74473e2) will increase coverage by 0.39%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #14646      +/-   ##
==========================================
+ Coverage   77.20%   77.59%   +0.39%     
==========================================
  Files         958      958              
  Lines       48492    49127     +635     
  Branches     5691     5767      +76     
==========================================
+ Hits        37437    38119     +682     
+ Misses      10855    10787      -68     
- Partials      200      221      +21     
Flag Coverage Δ
hive 81.26% <80.00%> (?)
javascript 72.37% <ø> (-0.16%) ⬇️
mysql 81.20% <80.00%> (-0.02%) ⬇️
postgres 81.23% <100.00%> (-0.01%) ⬇️
presto 80.92% <80.00%> (?)
python 82.08% <100.00%> (+0.80%) ⬆️
sqlite 81.18% <80.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
superset/databases/api.py 92.41% <ø> (ø)
superset/models/core.py 89.33% <100.00%> (-0.07%) ⬇️
...src/dashboard/components/dnd/handleScroll/index.ts 67.85% <0.00%> (-5.48%) ⬇️
superset/exceptions.py 99.13% <0.00%> (-0.87%) ⬇️
superset/reports/logs/api.py 94.59% <0.00%> (-0.86%) ⬇️
superset/app.py 81.23% <0.00%> (-0.15%) ⬇️
superset-frontend/src/dashboard/actions/hydrate.js 1.74% <0.00%> (-0.02%) ⬇️
superset/utils/urls.py 100.00% <0.00%> (ø)
...rset-frontend/src/dashboard/util/findPermission.ts 100.00% <0.00%> (ø)
... and 17 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 74473e2...5f30cee. Read the comment docs.

@property
def parameters(self) -> Optional[Dict[str, Any]]:
# Build parameters if db_engine_spec is a subclass of BasicParametersMixin
parameters = {"engine": self.backend}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so for sqlalchemy forms, we're only going to return engine? Maybe that should be the only required type then, it looks like.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea good catch i'll make sure to update the type on the types file

# Build parameters if db_engine_spec is a subclass of BasicParametersMixin
parameters = {"engine": self.backend}

if issubclass(self.db_engine_spec, BasicParametersMixin):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After we add BQ we need to change this, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea that PR will have the updated logic here to allow us to pass Big Query credentials

@hughhhh
Copy link
Member Author

hughhhh commented May 16, 2021

closing in favor of #14653

@hughhhh hughhhh closed this May 16, 2021
@mistercrunch mistercrunch deleted the hugh/add-parameters-api branch March 25, 2024 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants